package cn.ai.boot.config.PCF;


import java.util.Arrays;

/**
 * @author jie.zhao@dms365.com
 * @Date 2025/7/30 17:17
 * 国际化规则枚举
 */
public enum GenerationRuleEnum {

    REGULAR_RULE_CN("主线-分支规则", GenerationRuleConstant.REGULAR_RULE, "CN"),
    RULE_3558_CN("3558规则", GenerationRuleConstant.RULE_3558, "CN"),

    REGULAR_RULE_EN("REGULAR_RULE_EN", GenerationRuleConstant.REGULAR_RULE, "EN"),
    RULE_3558_EN("Rule_3558_EN", GenerationRuleConstant.RULE_3558, "EN"),

    NULL("", "", "");

    GenerationRuleEnum(String ruleName, String ruleCode, String language) {
        this.ruleName = ruleName;
        this.ruleCode = ruleCode;
        this.language = language;
    }

    private String ruleName;


    private String ruleCode;

    private String language;


    public String getRuleName() {
        return ruleName;
    }

    public String getRuleCode() {
        return ruleCode;
    }

    public String getLanguage() {
        return language;
    }

    // 通过ruleName获取规则编码
    public static GenerationRuleEnum getEnumByName(String name) {
        return Arrays.stream(GenerationRuleEnum.values())
                .filter(enumValue -> enumValue.getRuleName().equals(name))
                .findFirst()
                .orElse(NULL);
    }

    // 通过规则编码获取规则名称
    public static GenerationRuleEnum getEnumByCode(String code, String language) {
        return Arrays.stream(GenerationRuleEnum.values())
                .filter(enumValue ->
                        enumValue.getRuleCode().equals(code) &&
                                enumValue.getLanguage().equals(language))
                .findFirst()
                .orElse(NULL);
    }
}
